import 'package:flutter/material.dart';
import 'package:kasax_demos2/entry/data_posts_test.dart';
import 'package:kasax_demos2/entry/entrys.dart';

class CustomerViewDemo2 extends StatefulWidget {
  const CustomerViewDemo2({Key? key}) : super(key: key);

  @override
  _CustomerViewDemo2State createState() => _CustomerViewDemo2State();
}

class _CustomerViewDemo2State extends State<CustomerViewDemo2> {
  var gridDelegate =
      SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3);
  List<Posts> _list = PostsDatas.TEST_POSTS;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: CustomScrollView(slivers: [
      SliverAppBar(
        pinned: true,
        expandedHeight: 250,
        flexibleSpace: FlexibleSpaceBar(
          centerTitle: true,
          title: Text("泰山封禅"),
        ),
      ),
      SliverGrid(
        delegate: SliverChildBuilderDelegate((context, index) {
          var info = _list[index];
          return Container(
            alignment: Alignment.center,
            color: Colors.teal[100 * (index % 9)],
            child: Text(info.title),
          );
        }, childCount: _list.length),
        gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
          maxCrossAxisExtent: 200.0,
          mainAxisSpacing: 10.0,
          crossAxisSpacing: 10.0,
          childAspectRatio: 4.0,
        ),
      ),
      SliverFixedExtentList(
          delegate: SliverChildBuilderDelegate((context, index) {
            var info = _list[index];
            return Container(
              alignment: Alignment.center,
              color: Colors.lightBlue[100 * (index % 9)],
              child: Text(info.title),
            );
          }, childCount: _list.length),
          itemExtent: 50)
    ]));
  }
}
